<?php
/*
 * Copyright 2008 by Oliver Radwan, Maxwell Palmer, Nolan McNair,
 * Taylor Talmage, and Allen Tucker.  This program is part of RMH Homebase.
 * RMH Homebase is free software.  It comes with absolutely no warranty.
 * You can redistribute it and/or modify it under the terms of the GNU
 * General Public License as published by the Free Software Foundation
 * (see <http://www.gnu.org/licenses/ for more information).
*/

 include_once('RMHdate.php');
/*
 * Month is an array of dates
 * Months start on Mondays
 * For any date given to the constructor function,
 * the script will find the first day of that month and generate dates from there
 * @author Allen Tucker
 * @version 2/22/10
 */

class Month {
	private $id;	    // the first day of the month, mm-dd-yy
 	private $dates;     // array of 28, 29, 30, or 31 RMHdates
	private $name;      // name of the Month (ie March 2008)
	private $weekday_start; // weekday for the first day (0 = Sunday)
	private $days;      // number of days in the month
	private $timestamp;	// timestamp for the first day of the month

 	/**
 	 * Creates a new month for the calendar.
 	 */
 	function __construct($mm, $yy) {
 		$this->timestamp = mktime(0,0,0,$mm,1,$yy);
 		$this->days = date("t",$this->timestamp);
 		$this->dates[0] = new RMHDate($mm."-01-".$yy,null,"","");
        for ($i=1; $i<=8; $i++)
      	  $this->dates[] = new RMHDate($mm."-0".($i+1)."-".$yy,null,"","");
      	for ($i=9; $i<$this->days; $i++)
      	  $this->dates[] = new RMHDate($mm."-".($i+1)."-".$yy,null,"","");
 		$this->name=date("F, Y", $this->timestamp);
		$this->weekday_start=date("w", $this->timestamp);
		$this->id=$this->dates[0]->get_id();
 	}

	function get_name() {
		return $this->name;
	}
	function get_id() {
		return $this->id;
	}
	function get_dates() {
		return $this->dates;
	}
	function get_start() {
		return $this->weekday_start;
	}
	function get_days() {
		return $this->days;
	}
 }
 ?>
